set(SOURCE_DIR ${PROJECT_ROOT}/driver/serial)
set(HEADER_DIR ${PROJECT_ROOT}/include/driver)

qelib_include_directories(${HEADER_DIR})

qelib_sources(
    ${SOURCE_DIR}/serial.c)

set(INSTALL_HEADERS
    ${HEADER_DIR}/qe_serial.h)

# earlycon
qelib_sources_ifdef(CONFIG_EARLYCON ${SOURCE_DIR}/earlycon.c)
if(CONFIG_EARLYCON)
set(INSTALL_HEADERS ${INSTALL_HEADERS} ${HEADER_DIR}/qe_earlycon.h)
endif()

# Xilinx AXI UART16550
qelib_sources_ifdef(CONFIG_AXI_UART16550 ${SOURCE_DIR}/axi_uart16550.c)

# Xilinx AXI UARTLITE
qelib_sources_ifdef(CONFIG_AXI_UARTLITE ${SOURCE_DIR}/axi_uartlite.c)

# Xilinx PS7 UART
qelib_sources_ifdef(CONFIG_PS7_UART ${SOURCE_DIR}/ps7_uart.c)

# Xilinx PSU UART
qelib_sources_ifdef(CONFIG_PSU_UART ${SOURCE_DIR}/psu_uart.c)

# Xilinx Microblaze Debug Model
qelib_sources_ifdef(CONFIG_XLNX_MDM_EARLYCON ${SOURCE_DIR}/xlnx_mdm.c)

install(FILES ${INSTALL_HEADERS} DESTINATION ${QELIB_INSTALL_PATH}/include/driver)